# -*- coding:utf-8 -*-
from fastapi import APIRouter, Depends, Query, Request
from typing import Union
from core.request import get_page_info, get_query_param
from core.response import tableinfo, success
from core.curd import PageInfo
from app.annotation import RequiresPermissions, Log
from app.service.system import SysLogService
from core.constants import BusinessType

router = APIRouter()


@router.get('/login/list')
async def list1(req: Request,page=Depends(get_page_info), where=Depends(get_query_param),mService=Depends(SysLogService.instance)):
    """
        获取登录日志列表
    """
    where['log_type'] = '0'

    total, rows = await mService.select_page(page, where)
    return tableinfo('OK', total, rows)


@router.get('/operation/list')
# @Log(title="浏览日志", business_type=BusinessType.OTHER)
async def list2(req: Request, page=Depends(get_page_info), where=Depends(get_query_param),mService=Depends(SysLogService.instance)):
    """
        获取操作日志列表
    """
    where['log_type'] = '1'

    total, rows = await mService.select_page(page, where)
    return tableinfo('OK', total, rows)
